<%@page import="com.yunhuakeji.wddx.utils.IsNull"%>
<%@page import="net.sf.json.JSONObject"%>
<%@page import="net.sf.json.JSONArray"%>
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
/* action:*/
/* http://win10-702151553:8080/WDDXSERVER/homeapp/XXJHJump?userid=11204050220&function_id=20170201&authTime=2017031416361234&ticket=bdcbf7069153f634c78cf9ab87385096 */
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
JSONObject json;
String bs="";
try{
    json = JSONObject.fromObject(request.getAttribute("result"));  
    bs = request.getAttribute("bs").toString();
}
catch(Exception e){
    json = null;
}
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html> 
  <head>
    <base href="<%=basePath%>">
    <title>我要毕业</title>
     <meta name="viewport" content="width=device-width,initial-scale=1.0,user-scalable=no,minimum-scale=1.0,maximum-scale=1.0">
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
	<meta http-equiv="description" content="This is my page">
	<link rel="stylesheet" type="text/css" href="css/myreport.css">
	<link rel="stylesheet" type="text/css" href="css/selectStyle.css">
	<script src="js/jquery.min.js"></script>
	<script src="js/selectCustom.js"></script>
	<script src="js/highcharts.js"></script>
	<script src="js/myReport.js"></script>
	<script src="js/layer.js"></script>
  </head>
  <style>
  	
  </style>
  <body>
  <%if(IsNull.isNotNull(json.toString())){ %>
  	<!-- 学习计划 -->
  	<div class="liner-blue-yellowgreen graduate-banner">
  		<div class="pt20 text-center" id="Dashboard">
  			<div class="position-relative">
  				<img src="images/graduate_01.png"/>
  				<div class="dboard_01" id="dashbord_01">
  					<img src="images/dkdhn1d.png"/>
  				</div>
  				<div class="dboard_02">
  					<img src="images/dkdhnd.png"/>
  				</div>
  				<div class="dboard_03">
  					<div>已得学分</div>
  					<div style="font-size:20px;"><b><%=JSONObject.fromObject(json.getJSONArray("xf").get(0)).getString("xf") %></b></div>
  					<div><%=JSONObject.fromObject(json.getJSONArray("xf").get(0)).getString("times") %></div>
  				</div>
  			</div>
  			<div class="mt20">
  				<a class="my-btn-default">
  					挂科<%=JSONObject.fromObject(json.getJSONArray("xf").get(0)).getString("count") %>门
  				</a>
  			</div>
  		</div>
  	</div>
	<!--   	tab切换 -->
	<div class="bg-color-lightGreen graduate_tab">
		<ul>
			<li name="xxjh">
				<div>
					<img src="images/graduate-wdcj.png"/>
				</div>
				<a>
					<b>学习计划</b>
				</a>
			</li>
			<li name="wdcj" onclick="loadWdcj();">
				<div>
					<img src="images/graduate-xxjh.png"/>
				</div>
				<a>
					<b>我的成绩</b>
				</a>
			</li>
			<li name="gkyj" onclick="loacGk();">
				<div>
					<img src="images/graduate-gkyj.png"/>
				</div>
				<a>
					<b>挂科预警</b>
				</a>
			</li>
			<div class="clear"></div>
		</ul>
	</div>
	<!-- grid学习预警 -->
	<table id="gkyj" class="plan">
		<tbody>
			<tr class="table-head-lightGreen">
				<td>课程名称</td>
				<td>类别</td>
				<td>成绩</td>
				<td>学分</td>
			</tr><!-- 
			<tr>
				<td>大学英文I</td>
				<td>必修课</td>
				<td>58</td>
				<td>3</td>
			</tr>
			<tr>
				<td>大学英文I</td>
				<td>必修课</td>
				<td>58</td>
				<td>3</td>
			</tr>
			<tr>
				<td>大学英文I</td>
				<td>必修课</td>
				<td>58</td>
				<td>3</td>
			</tr> -->
		</tbody>
	</table>
	<!-- grid学习计划 -->
	<div id="xxjh" class="plan">
		<div class="graduate_xxjh">
			<a href="javascript:;" name="xxjh_xq">按学期</a>
			<a href="javascript:;" name="xxjh_kclb">课程类别</a>
			<div class="clear"></div>
		</div>
		<ul class="graduate_xxjh_ul active" id="xxjh_xq">
			 <%JSONArray xnxq = JSONArray.fromObject(json.get("xxjh_xnxq"));for(int i=0, len= xnxq.size();i<len;i++){ %> 
			<li>
				<div>
					<a>
						<img src="images/graduate_jia.png"/>
					</a>
					<span><%=JSONObject.fromObject(xnxq.get(i)).get("xq") %></span>
				</div>
				<table>
					<tbody>
						<tr class="table-head-lightGreen">
							<td>课程名称</td>
							<td>类别</td>
							<td>成绩</td>
							<td>学分</td>
						</tr>
					 	<%JSONArray con = JSONArray.fromObject(JSONObject.fromObject(xnxq.get(i)).get("content"));for(int j=0,len1=con.size();j<len1;j++){ %>
						<tr>
							<td><%=JSONObject.fromObject(con.get(j)).get("kcmc") %></td>
							<td><%=JSONObject.fromObject(con.get(j)).get("kclb") %></td>
							<td><%=JSONObject.fromObject(con.get(j)).get("cj") %></td>
							<td><%=JSONObject.fromObject(con.get(j)).get("xf") %></td>
						</tr>
						<%} %> 
					</tbody>
				</table> 
			</li>
			<%} %>
		</ul>
		<ul class="graduate_xxjh_ul" id="xxjh_kclb">
			<%JSONArray kclb = JSONArray.fromObject(json.get("xxjh_kclb"));for(int i=0, len= kclb.size();i<len;i++){ %> 
			<li>
				<div>
					<a>
						<img src="images/graduate_jia.png"/>
					</a>
					<span><%=JSONObject.fromObject(kclb.get(i)).get("zy") %></span>
				</div>
				<table>
					<tbody>
						<tr class="table-head-lightGreen">
							<td>课程名称</td>
							<td>类别</td>
							<td>成绩</td>
							<td>学分</td>
						</tr>
					 	<%JSONArray con1 = JSONArray.fromObject(JSONObject.fromObject(kclb.get(i)).get("content"));for(int j=0,len1=con1.size();j<len1;j++){ %>
						<tr>
							<td><%=JSONObject.fromObject(con1.get(j)).get("kcmc") %></td>
							<td><%=JSONObject.fromObject(con1.get(j)).get("kclb") %></td>
							<td><%=JSONObject.fromObject(con1.get(j)).get("cj") %></td>
							<td><%=JSONObject.fromObject(con1.get(j)).get("xf") %></td>
						</tr>
						<%} %> 
					</tbody>
				</table> 
			</li>
			<%} %>
	    </ul>
	</div>
	<!-- grid我的成绩-->
	<div id="wdcj" class="plan">
	    <ul class="graduate_xxjh_ul active">
		</ul>
	</div>
	<%} %>
  	<script>
  //ajax 获取数据源
  	var xuefen =<%=JSONObject.fromObject(json.getJSONArray("xf").get(0)).getString("xf") %>;
  	var deg = xuefen*1.5-180;
  	var d = $("#dashbord_01");
  	var report = new myReport();
  	var bs = "<%=bs%>";
  	report.dashbord(d,deg);
  //默认加载显示
  	$(".graduate_tab ul li").each(function(i,r){
  		if($(r).hasClass("active")){
  			$("#"+$(r).attr("name")).addClass("active");
  		}
  	});
  	if(bs){
  	    $(".graduate_tab ul li[name="+bs+"]").addClass("active");
  	    if(bs=="gk"){
	  		$("#"+bs).css("display","table");
  	    }else{
	  		$("#"+bs).addClass("active");
  	    }
  	}
  //绑定tab切换
  	$(".graduate_tab li").bind('click',function(){
  	    if($(this).attr("name")=="gkyj"){
  	        $(".graduate_tab li").removeClass("active");
	  		$('.plan').removeClass("active");
	  		$("#"+$(this).attr('name')).css("display","table");
	  		$(this).addClass("active");
  	    }else{
  	        $("#gkyj").css("display","none");
	  	    $(".graduate_tab li").removeClass("active");
	  		$('.plan').removeClass("active");
	  		$("#"+$(this).attr('name')).addClass("active");
	  		$(this).addClass("active");
  	    }
  	});
   //学期  课程类别 切换
   $('.graduate_xxjh a').click(function(){
       $("#xxjh ul.graduate_xxjh_ul").removeClass("active");
       $("#"+$(this).attr("name")).addClass("active");
   });
  //绑定展开图标
  $(".graduate_xxjh_ul li div a").bind('click',function(){
  	if($(this).parent().next("table").css("display")=="table"){
  		$(this).children("img").attr("src","images/graduate_jia.png");
  		$(this).parent().next("table").css("display","none");
  	}else{
  		$(this).children("img").attr("src","images/graduate_jian.png");
  		$(this).parent().next("table").css("display","table");
  	}
  });
  //加载数据
  function loadWdcj(){
     if($('#wdcj ul').children().length>0){
         return false;
     }
      $.ajax({
         url:'homeapp/getCjWithAppJson?userid=11204050220&ticket=11',
         type:'post',
         dataType:'json',
         success:function(data){
            var json = eval('('+data+')');
            var cj=json["cj"];
            var html="";
            $.each(cj,function(i,r){
                  html += '<li>'
				            +'<div>'
					            +'<a>'
						        +'<img src="images/graduate_jia.png"/>'
					            +'</a>'
					            +'<span>'+r["xq"]+'</span>'
				            +'</div>'
				            +'<table>'
					            +'<tbody>'
					               +'<tr class="table-head-lightGreen">'
							            +'<td>'+"课程名称"+'</td>'
							            +'<td>'+"类别"+'</td>'
							            +'<td>'+"成绩"+'</td>'
							            +'<td>'+"学分"+'</td>'
						           +'</tr>';
				  $.each(r["content"],function(index,rec){
				       html += '<tr>'
									+'<td>'+rec["kcmc"]+'</td>'
									+'<td>'+rec["kclb"]+'</td>'
									+'<td>'+rec["cj"]+'</td>'
									+'<td>'+rec["xf"]+'</td>'
								+'</tr>';
				  });
				  html +='</tbody></table></li>';
            });
             $("#wdcj ul").append(html);
             $(".graduate_xxjh_ul li div a").unbind().bind('click',function(){
			  	if($(this).parent().next("table").css("display")=="table"){
			  		$(this).children("img").attr("src","images/graduate_jia.png");
			  		$(this).parent().next("table").css("display","none");
			  	}else{
			  		$(this).children("img").attr("src","images/graduate_jian.png");
			  		$(this).parent().next("table").css("display","table");
			  	}
  });
         }
      }); 
  }
  function loacGk(){
     if($('#gkyj tbody').children().length>1){
         return false;
     }
    $.ajax({
         url:'homeapp/getGkWithAppJson?userid=11204050220&ticket=11',
         type:'post',
         dataType:'json',
         success:function(data){
            var json = eval('('+data+')');
            var cj=json["gk"];
            var html = "";
            $.each(cj,function(i,r){
                 html += '<tr>'
							+'<td>'+r["class_name"]+'</td>'
							+'<td>'+r["class_type"]+'</td>'
							+'<td>'+r["class_score"]+'</td>'
							+'<td>'+r["class_credit"]+'</td>'
						+'</tr>';
            });
            $("#gkyj tbody").append(html);
            }
         });
  }
  	</script>
  </body>
</html>
